package com.demo.rabbitmq.demo.topics;

import com.demo.rabbitmq.util.RabbitMQUtil;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {

    //交换机名称
    static final String TOPIC_EXCHAGE = "topic_exchange";
    //列队名称
    static final String TOPIC_QURUE_1 = "topic_queue_1";
    static final String TOPIC_QURUE_2 = "topic_queue_2";

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitMQUtil.getConnection();

        Channel channel = connection.createChannel();
        //声明交换机
        channel.exchangeDeclare(TOPIC_EXCHAGE, BuiltinExchangeType.TOPIC);
        //发送消息
        channel.basicPublish(TOPIC_EXCHAGE,"item.insert",null,"新增 topic模式 item.insert".getBytes());
        channel.basicPublish(TOPIC_EXCHAGE,"item.update",null,"新增 topic模式 item.update".getBytes());
        channel.basicPublish(TOPIC_EXCHAGE,"item.delete",null,"新增 topic模式 item.delete".getBytes());
        channel.close();
        connection.close();


    }
}
